<template>
  <el-table :data="data" border style="width: 100%" :default-sort="{order:'descending'}" >
    <el-table-column
      type="index"
      width="60"
      fixed="left"
      >
    </el-table-column>
    <!-- <el-table-column :label="item.label" v-for="(item,index) in tableData">
      <el-table-column
        v-for="(option,optIndex) in item.data"
        :prop="option.props"
        :label="option.label"
        :min-width="option.width||120"
        :key="optIndex"
        :show-overflow-tooltip="true"
        >
      </el-table-column>
    </el-table-column> -->

    <el-table-column 
      v-for="(item,index) in formaltTableData"
      :label="item.label" 
      :prop="item.props" 
      :min-width="item.width||150" 
      :key="index"
      :fixed="index<1"
      :show-overflow-tooltip="true">

    </el-table-column>

    <el-table-column
      label="操作"
      width="80"
      fixed="right">
      <template slot-scope="scope">
        <!-- 查看 -->
        <span v-if="showValue==1" v-for="(item, index) in btn" :key="index" :class="item.className" @click="item.click(scope)">{{item.label}}</span>
        <!-- 审核 -->
        <span v-if="showValue==2" :class="{'more-info':scope.row.sta===''}" @click="doCheck(scope)">
          {{scope.row.sta===''?"待审核":scope.row.sta==='0'?"不通过":"通过"}}
        </span>
      </template>
    </el-table-column>
  </el-table>
</template>
<script>
export default {
  props:["data","tableData","table"],
  components: {},
  name: "",
  data() {
    return {
      btn:[],
      showValue:1,
      btnsData:[
        {
          key:["/student"],
          value:1,
          data:[
            {label:"查看",className:"more-info",click:this.showMoreInfo}
          ]
        },{
          key:[
            "/academicpaper",
            "/scientificawards",
            "/teachmaterial",
            "/softwork",
            "/joinactivity",
            "/runmeeting",
            "/competition",
            "/guidance",
            "/otherteaching",
            "/famoust",
            "/classChange",
            "/researchs",
            "/teachingpaper",
            "/textbooks",
            "/honorary",
            "/professional",
            "/teaching/results",

            "/teaching/project",
            "/teaching/appraise",
            "/teaching/reform",
            "/teaching/course"
          ],
          value:2,
          data:[
            {label:"审核",className:"more-info",click:this.doCheck},
            {label:"不通过",className:"no-pass",click:function(){}},
            {label:"通过",className:"pass",click:function(){}},
          ]
        }
      ]
    };
  },
  computed: {
    formaltTableData(){
      let goals=[]
      this.tableData.forEach(ele=>{
        goals=goals.concat(ele.data)
      })
      return goals
    }
  },
  methods: {
    // 查看更多信息
    showMoreInfo(scope){
      this.$router.push("/student/detail/"+scope.row.id+"?id=info")
      this.$store.state.theader.label="学生详情"
    },

    // 审核
    doCheck(scope){
      if(scope.row.sta===''){
        this.$store.state.examine.show=true
        this.$store.state.examine.info={...scope.row}
      }
    },

    setOperation(){
      var path = _g.getRouterPath(this)
      this.btnsData.forEach(ele=>{
        if(ele.key.includes(path)){
          this.showValue=ele.value
          this.$set(this,"btn",ele.data)
          return
        }
      })
    },
  },
  created() {
    this.setOperation()
  }
};
</script>
<style scoped>
.table-content-1 {
}
.more-info{
  color: #3f9ce2;
  cursor: pointer;
}
.no-pass,.pass{
  color: #666
}
</style>